package org.c41.util.collection;

import java.util.Iterator;

import org.c41.system.ImpossibleException;
import org.c41.system.Tools;

@Tools
public final class Iter {

	private Iter(){
		throw new ImpossibleException();
	}
	
	public static <T> void iter(Iterable<T> it, IterTask<T> task){
		Iterator<T> iterator = it.iterator();
		int index = 0;
		while(iterator.hasNext()){
			T t = iterator.next();
			if(!task.iter(t, index)){
				return;
			}
			index++;
		}
	}
	
}
